package com.jgzx.log;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author jackesy
 * @className: FilterConfig
 * @description: 过滤器配置
 * @create 2020/12/4 0004 20:15
 **/
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean registFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new WebLogFilter());
        registration.addUrlPatterns("/*");
        registration.setName("LogFilter");
        registration.setOrder(1);
        registration.setEnabled(false);//一定要设置false 否则过滤器执行两次
        return registration;
    }

}
